import http from "@/utils/http";
import { AxiosRequestConfig } from "axios";

export interface GetModelColumnDetail_ {
  /**
   * @description id
   * @format int32
   */
  id?: number;
  /**
   * @description 库id
   */
  schemaId?: string;
  /**
   * @description 表id
   */
  tableId?: string;
}
export interface DeleteModelDeleteById_ {
  /**
   * @description id
   */
  id: number;
}
export interface GetModelDimensionListById_ {
  /**
   * @description id
   */
  id: number;
}
export interface GetModelList_ {
  /**
   * @description 搜索条件
   */
  content?: string;
  /**
   * @description 创建人
   */
  createBy?: string;
  /**
   * @description 模型类型
   */
  modelType?: "DIM" | "DWD" | "DWS";
  /**
   * @description 排序顺序,可选的值1:asc:、2:desc，默认2。
   * @format int32
   */
  order?: number;
  /**
   * @description 页数
   * @format int32
   */
  pageNum?: number;
  /**
   * @description 条数
   * @format int32
   */
  pageSize?: number;
  /**
   * @description 排序条件,可选的值modelName、id、createBy、updateBy、updateTime,默认modelName
   */
  sortBy?: string;
  /**
   * @description 模型状态
   * @format int32
   */
  status?: number;
  /**
   * @description 主题id
   * @format int32
   */
  subjectId?: number;
}
export interface GetModelSimpleList_ {
  /**
   * @description 模糊查询,支持id或名字
   */
  content?: string;
  /**
   * @description 模型类型
   */
  modelType?: "DIM" | "DWD" | "DWS";
  /**
   * @description 页数
   * @format int32
   */
  pageNum?: number;
  /**
   * @description 条数
   * @format int32
   */
  pageSize?: number;
  /**
   * @description 主题id
   * @format int32
   */
  subjectId?: number;
}
export interface GetModelSimpleListByDimId_ {
  /**
   * @description 绑定字段id
   */
  bindIds?: number[];
  /**
   * @description columnModelType
   */
  columnModelType: string;
  /**
   * @description DIMENSION/METRICS/TIMEPERIOD
   */
  dimType?: string;
  /**
   * @description 主模型id
   * @format int32
   */
  mainModelId?: number;
  /**
   * @description 模型类型
   */
  modelType?: "DIM" | "DWD" | "DWS";
  /**
   * @description 页数
   * @format int32
   */
  pageNum?: number;
  /**
   * @description 条数
   * @format int32
   */
  pageSize?: number;
  /**
   * @description 主题id
   * @format int32
   */
  subjectId?: number;
}
export interface PutModelStatusById_ {
  /**
   * @description 模块状态（1-正常,0-禁用）
   * @format int32
   */
  status?: number;
  /**
   * @description 模块id
   * @format int32
   */
  id?: number;
}
export interface GetModelTableEntity_ {
  /**
   * @description 关键字
   */
  content?: string;
  /**
   * @description 层级id
   */
  layer?: string;
  /**
   * @description 主题域id
   */
  topicId?: string;
}
export interface GetModelById_ {
  /**
   * @description id
   */
  id: number;
}
export interface PutModelById_ {
  /**
   * @description id
   */
  id: number;
}

export class Model {
  /**
   * 库表方式新增模型数据
   *
   * @tags 模型管理controller
   * @request POST: /model
   * @secure
   */
  postModel = (modelDTO: defs.ModelDTO, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityModelVO>({
      url: `/model`,
      method: "POST",
      data: modelDTO,
      ...params,
    });

  /**
   * 根据schemaId和table获取表字段
   *
   * @tags 模型管理controller
   * @request GET: /model/column-detail
   * @secure
   */
  getModelColumnDetail = (
    query: { id?: number; schemaId?: string; tableId?: string } | GetModelColumnDetail_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityListModelColumnInfoVO>({
      url: `/model/column-detail`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 删除模型
   *
   * @tags 模型管理controller
   * @request DELETE: /model/delete/{id}
   * @secure
   */
  deleteModelDeleteById = ({ id }: { id: number } | DeleteModelDeleteById_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityString>({
      url: `/model/delete/${id}`,
      method: "DELETE",
      ...params,
    });

  /**
   * 获取某个模型下的所有维度信息
   *
   * @tags 模型管理controller
   * @request GET: /model/dimension-list/{id}
   * @secure
   */
  getModelDimensionListById = ({ id }: { id: number } | GetModelDimensionListById_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityListDimensionVO>({
      url: `/model/dimension-list/${id}`,
      method: "GET",
      ...params,
    });

  /**
   * 获取所有layer层级
   *
   * @tags 模型管理controller
   * @request GET: /model/layer
   * @secure
   */
  getModelLayer = (params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityListMetaLayerVO>({
      url: `/model/layer`,
      method: "GET",
      ...params,
    });

  /**
   * 查询模型列表
   *
   * @tags 模型管理controller
   * @request GET: /model/list
   * @secure
   */
  getModelList = (
    query:
      | {
          content?: string;
          createBy?: string;
          modelType?: "DIM" | "DWD" | "DWS";
          order?: number;
          pageNum?: number;
          pageSize?: number;
          sortBy?: string;
          status?: number;
          subjectId?: number;
        }
      | GetModelList_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityPageInfoModelVO>({
      url: `/model/list`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 获取模型类型枚举
   *
   * @tags 模型管理controller
   * @request GET: /model/model-type-enum
   * @secure
   */
  getModelModelTypeEnum = (params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityHashMapStringString>({
      url: `/model/model-type-enum`,
      method: "GET",
      ...params,
    });

  /**
   * 通过模型类型或主题类型筛选模型list
   *
   * @tags 模型管理controller
   * @request GET: /model/simple-list
   * @secure
   */
  getModelSimpleList = (
    query:
      | { content?: string; modelType?: "DIM" | "DWD" | "DWS"; pageNum?: number; pageSize?: number; subjectId?: number }
      | GetModelSimpleList_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityPageInfoModelVO>({
      url: `/model/simple-list`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 通过绑定字段id筛选模型list
   *
   * @tags 模型管理controller
   * @request GET: /model/simple-list-by-dimId
   * @secure
   */
  getModelSimpleListByDimId = (
    query:
      | {
          bindIds?: number[];
          columnModelType: string;
          dimType?: string;
          mainModelId?: number;
          modelType?: "DIM" | "DWD" | "DWS";
          pageNum?: number;
          pageSize?: number;
          subjectId?: number;
        }
      | GetModelSimpleListByDimId_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityPageInfoModelRelVO>({
      url: `/model/simple-list-by-dimId`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 改变模型状态
   *
   * @tags 模型管理controller
   * @request PUT: /model/status/{id}
   * @secure
   */
  putModelStatusById = (
    { id, ...query }: { status?: number; id?: number } | PutModelStatusById_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityModelVO>({
      url: `/model/status/${id}`,
      method: "PUT",
      params: query,
      ...params,
    });

  /**
   * 根据topicId和layer获取层级主题域下的库与表
   *
   * @tags 模型管理controller
   * @request GET: /model/table-entity
   * @secure
   */
  getModelTableEntity = (
    query: { content?: string; layer?: string; topicId?: string } | GetModelTableEntity_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityListMetaTableVO>({
      url: `/model/table-entity`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 获取所有topic主题域
   *
   * @tags 模型管理controller
   * @request GET: /model/topic
   * @secure
   */
  getModelTopic = (params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityListMetaTopicVO>({
      url: `/model/topic`,
      method: "GET",
      ...params,
    });

  /**
   * 根据模型id查看模型信息
   *
   * @tags 模型管理controller
   * @request GET: /model/{id}
   * @secure
   */
  getModelById = ({ id }: { id: number } | GetModelById_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityModelVO>({
      url: `/model/${id}`,
      method: "GET",
      ...params,
    });

  /**
   * 修改模型数据
   *
   * @tags 模型管理controller
   * @request PUT: /model/{id}
   * @secure
   */
  putModelById = ({ id }: { id: number } | PutModelById_, modelDTO: defs.ModelDTO, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityModelVO>({
      url: `/model/${id}`,
      method: "PUT",
      data: modelDTO,
      ...params,
    });
}

export default new Model();
